const webpack = require("webpack");
const path = require("path");

module.exports = {
    lintOnSave: false,
    publicPath: "./",
    outputDir: "dspw2",
    productionSourceMap: false,
    runtimeCompiler: true,
    css: {
        loaderOptions: {
            sass: {
                data: '@import "@/common/theme/_theme.scss";'
            }
        }
    },
    // chainWebpack: config => {
    //     config.plugins.delete("prefetch");
    //     if (process.env.NODE_ENV === "production") {
    //         config.plugin("compression").use(CompressionWebpackPlugin, [
    //             {
    //                 test: /\.js$|\.css$/,
    //                 algorithm: "gzip",
    //                 threshold: 0
    //             }
    //         ]);
    //     }
    // },
    devServer: {
        port: 9999, // 端口号
        host: "0.0.0.0",
        https: false, // https:{type:Boolean}
        open: true, //配置自动启动浏览器
        proxy: {
            "/share": {
                target: "http://192.168.33.163:8888",
                changeOrigin: true,
                pathRewrite: {
                    "^/share": ""
                }
            },
        }
    },

    configureWebpack: {
        resolve: {
            alias: {
                "@": path.resolve(__dirname, "src")
            }
        },
        module: {
            rules: [
                {
                    test: /\.txt|\.html/,
                    use: "raw-loader"
                },
                {
                    test: /.md$/,
                    use: 'text-loader',        
                 }
            ]
        },
        plugins: [
            new webpack.ProvidePlugin({
                Axios: "axios",
                // Utils: path.resolve(__dirname, "src/common/utils")
                // CONSTANT: path.resolve(__dirname, "src/config/constant.js")
            }),
            /* new UglifyJSPlugin({
                       exclude: ['/node_modules/']
                   })*/
        ]
    }
};
